<%--                                                                       --%>
<%-- Copyright (c) 2003-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.broadvision.ssp.common.NotifyRuntimeSpec" %>
<%@ page import="com.broadvision.visitor.client.VisitorManager" %>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%
  String ctxPath = request.getContextPath();
%>

<jsp:useBean id="processInstanceTasksForm" 
          class="com.broadvision.process.tools.action.process.ProcessInstanceTasksForm"
          scope="session"/>
<%! static VisitorManager vMgr = new VisitorManager();
%>
<%
  java.util.HashMap map= new java.util.HashMap();
  String instanceOid = request.getParameter("instanceOid"); 
  if (instanceOid!=null && instanceOid.length() > 0)
    map.put("instanceOid",instanceOid);
  map.put("currentTask",request.getParameter("currentTask"));
  pageContext.setAttribute("pagetabParam",map);
%>

<c:set var="editImg">
<img src="<%= ctxPath %>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.edit" bundle="mc.messages"/>" title="<bean-el:message key="image.alt.edit" bundle="mc.messages"/>">
</c:set>

<html-el:form action="/bp/processInstanceNotification.do?action=new">
<input type="hidden" name="currentTask" value="<%= request.getParameter("currentTask") %>" />
<!--start zone 5 content area-->

    <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.process.processInstance.contentArea" bundle="bp.messages"/>">
      <tr>
        <td valign="top" width="100%">
          <div class="pageTitle"><bean:write name="processInstanceTasksForm" property="currentMinorTask" />
          </div>
          <%@include file="/mc/common/pagetab.jsp" %>
        <div class="breadcrumb">
          <html-el:link page="/bp/processInstanceTasks.do"  paramId="instanceOid" paramName="processInstanceTasksForm"  paramProperty="instanceOid"><bean:write name="bpProcessInstanceForm" property="processInstance.customId" /></html-el:link>&nbsp;>&nbsp;<bean:write name="processInstanceTasksForm" property="currentMinorTask" /></div>
          <div class="pageSubtitle">
            <span class="left"><bean:message key="bp.process.processInstanceNotify.title" bundle="bp.messages"/></span>
          </div> 
          <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="<bean:message key="bp.process.processInstanceNotify.summary" bundle="bp.messages"/>" width="100%">
            <tr><td class="errorMessage" colspan="2"><html-el:errors  bundle="bp.messages"/></td></tr>
            <tr class="listHeader"> 
              <th  align="left"><bean:message key="bp.process.processInstanceNotify.notifyType" bundle="bp.messages"/></th>
              <th  align="left"><bean:message key="bp.process.processInstanceNotify.deliveryType" bundle="bp.messages"/></th>
              <th  align="left"><bean:message key="bp.process.processInstanceNotify.user" bundle="bp.messages"/></th>
              <th id="Actions" align="left"><bean:message key="bp.process.processInstanceSearch.action" bundle="bp.messages"/></th>
            </tr>
          <%  
            List[] ntSpecs = processInstanceTasksForm.getNotifySpec();
            if (ntSpecs != null) {
              for (int i=0; i < ntSpecs.length; i++) {

               List ntl = ntSpecs[i];
               if (ntl == null) continue;
               NotifyRuntimeSpec nt = (NotifyRuntimeSpec)ntl.get(0);
               if ( ( i % 2 ) == 0 ) { %>
                <tr class="listEven"> 
          <% }else{ %>
          <tr class="listOdd">
          <% } %>
                <td headers="Name"><bean:message key="<%=\"bp.process.processInstanceNotify.\"+nt.getNotifyType().toString()%>" bundle="bp.messages"/></td>
                <td headers="Name"><bean:message key="<%=\"bp.process.processInstanceNotify.\"+nt.getDeliveryType().toString()%>" bundle="bp.messages"/></td>
                <td headers="Name">
                <% for (Iterator t = ntl.iterator();t.hasNext();) { 
                  NotifyRuntimeSpec nt_in_group = (NotifyRuntimeSpec)t.next();%>
                  <%= nt_in_group.getUserId()==0?"":(vMgr.getVisitor(nt_in_group.getUserId())).getName()%><br>
                <% } %>
                </td>
                <td headers="Actions">
                  <a href="<%= response.encodeURL( ctxPath + "/bp/processInstanceNotification.do?action=edit&currentTask="+request.getParameter("currentTask")+"&notifyIndex="+ i)%>"><c:out value='${editImg}' escapeXml="false"/></a>
                </td>
              </tr>
           <%   } // end of loop 
              } else { %>
              <tr><td>&nbsp;</td></tr>
            <% } %>              
          </table>
        </td>
      </tr>
    </table>


<!--end main content area here-->
<!--end zone 5 content area-->

</html-el:form>
